<?php 
header("content-type:text/html;charset=utf8");
include_once("Classes/PHPExcel.php");
//找到excel表
$excel = PHPExcel_IOFactory::load("text.xlsx");
$sheet = $excel->getActiveSheet();
$rows = $sheet->getHighestRow();
$col = $sheet->getHighestColumn();
// print_r($col);
for ($i=2; $i <=$rows; $i++) { 
	for ($j='A'; $j <=$col; $j++) { 
		$data[$i-2][]=$sheet->getcell($j.$i)->getValue();
	}
}
// print_r($data);die;
foreach ($data as $key => $value) {
	$names=$value[0];
	$times = $value[1];
	// print_r($times);die;
	$num = $value[2];
	$jiaoshi = $value[3];
	$pdo = new PDO("mysql:host=127.0.0.1;dbname=07c;","root","root");
	$sql = "insert into xinxi values('','$names','$times','$num','$jiaoshi')";
	$res = $pdo->exec($sql);
}
// print_r($data);
if($res)
{
	echo "<script>alert('添加成功');location.href='show.php';</script>";
}
else
{
	echo "<script>alert('添加失败');location.href='show.php';</script>";
}


 ?>